﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WaterBill.DTO;
using WaterBill.DAL;
using System.Data;

namespace WaterBill.BUS
{
    class BUS_Users : DAL_Users
    {
        DataTable dtU;

        //Kiem tra dang nhap
        public DataTable BUS_Users_checKLogin(string UserName, string Password)
        {
            dtU = new DataTable();
            dtU = DAL_Users_checKLogin(UserName, Password);    
            return dtU;
        }

        //Kiem tra ton tai ten dang nhap
        public Boolean BUS_Users_CheckExist(string UserName)
        {
            if (DAL_Users_CheckExist(UserName))
            {
                return true;
            }
            return false;
        }

        //Them mot nguoi dung moi
        public Boolean BUS_Users_Insert(DTO_Users obj)
        {
            if (DAL_Users_Insert(obj))
            {
                return true;
            }
            return false;
        }

        //Sua nguoi dung
        public Boolean BUS_Users_Update(DTO_Users obj)
        {
            if (DAL_Users_Update(obj))
            {
                return true;
            }
            return false;
        }

        //Doi mat khau nguoi dung
        public Boolean BUS_Users_ChangePassword(DTO_Users obj)
        {
            if (DAL_Users_ChangePassword(obj))
            {
                return true;
            }
            return false;
        }

        //Lay danh sach tat ca nguoi dung
        public DataTable BUS_Users_GetAll()
        {
            dtU = new DataTable();
            dtU = DAL_Users_GetAll();
            return dtU;
        }

        //Lay danh sach nguoi dung dua vao quyen
        public DataTable BUS_Users_GetByPermission(int PermissionId)
        {
            dtU = new DataTable();
            dtU = DAL_Users_GetByPermission(PermissionId);
            return dtU;
        }

        //Lay danh sach nguoi dung dua vao quyen
        public DataTable BUS_Users_GetByUserId(int UserId)
        {
            dtU = new DataTable();
            dtU = DAL_Users_GetByUserId(UserId);
            return dtU;
        }

        //Xoa nguoi dung
        public Boolean BUS_Users_Delete(int UserId)
        {
            if (DAL_Users_Delete(UserId))
            {
                return true;
            }          
            return false;
        }

        public string BUS_Md5(string str)
        {
            return DAL_Md5(str);
        }
    }
}
